#include "../../../common/data_es.hpp"
#include <gflags/gflags.h>
#include <iostream>
DEFINE_bool(run_mode, false, "程序的运行模式, false-调试； true-发布；");
DEFINE_string(log_file, "", "发布模式下, 用于指定日志的输出文件");
DEFINE_int32(log_level, 0, "发布模式下, 用于指定日志输出等级");


DEFINE_string(es_host, "http://127.0.0.1:9200/", "es服务器URL");

int main(int argc, char *argv[])
{ 
    google::ParseCommandLineFlags(&argc, &argv, true);
    init_logger();

    auto es_client = ESClientFactory::create({FLAGS_es_host});

    auto es_user = std::make_shared<ESUser>(es_client); 
    // es_user->createIndex();
    // es_user->appendData("用户ID1", "小猪佩奇", "手机号1", "这是一只小猪", "小猪头像1");
    // es_user->appendData("用户ID2", "小猪乔治", "手机号2", "这是一只小小猪", "小猪头像2");
    es_user->appendData("id3", "萝卜子1", "");
    es_user->appendData("id4", "萝卜子2", "", "高性能机器人2号");
    es_user->appendData("id5", "萝卜子roboko0", "", "高性能笨蛋机器人");
    es_user->appendData("e7b5-538ed478-0001", "roboko2", "");
    auto res = es_user->search("子", {"用户ID1"});
    for (auto &u : res) {   
        std::cout << "-----------------" << std::endl;
        std::cout << u.user_id() << std::endl;
        std::cout << u.phone() << std::endl; 
        std::cout << u.user_name() << std::endl;
        std::cout << u.description() << std::endl;
        std::cout << u.avatar_id() << std::endl;
    }
    LOG_DEBUG("{}", res.size());
    return 0;
}